import request from '@/utils/request';

// 是否启动保存配置
export async function payTypeInsertSelective(data) {
  const res = await request.post('/business/paytype/insertSelective', data);
  if (res.data.code === 2000) {
    return res.data;
  }
  // console.log(res)
  // return res
  return Promise.reject(new Error(res));
}
//  是否启动查询配置
export async function payTypeSelectByPrimaryKey(data) {
  const res = await request.post(
    '/business/paytype/selectByPrimaryMerchantId',
    data
  );
  if (res.data.code === 2000) {
    return res.data;
  }
  // console.log(res)
  // return res
  return Promise.reject(new Error(res));
}

// 支付配置页新增接口
export async function insertSelective(data) {
  const res = await request.post(
    '/business/merchantpayparameter/insertSelective',
    data
  );
  if (res.data.code === 2000) {
    return res.data;
  }
  // console.log(res)
  // return res
  return Promise.reject(new Error(res));
}

// 支付配置页修改接口

export async function updateByPrimaryKey(data) {
  const res = await request.post(
    '/business/merchantpayparameter/updateByPrimaryKey',
    data
  );
  if (res.data.code === 2000) {
    return res.data;
  }
  // console.log(res)
  // return res
  return Promise.reject(new Error(res));
}

// 支付配置页查询

export async function selectByPrimaryMerchantId(data) {
  const res = await request.post(
    '/business/merchantpayparameter/selectByPrimaryMerchantId',
    data
  );
  if (res.data.code === 2000) {
    return res.data;
  }
  // console.log(res)
  // return res
  return Promise.reject(new Error(res));
}
// 设置费率

export async function settingsHandlingCharge(data) {
  const res = await request.post(
    '/business/wechatpay/settingsHandlingCharge',
    data
  );
  if (res.data.code === 2000) {
    return res.data;
  }
  // console.log(res)
  // return res
  return Promise.reject(new Error(res));
}

// 获取上传的MediaId
export async function wxGetUploadMediaId(data) {
  const res = await request.post('/business/wechatpay/getUploadMediaId', data);
  // if (res.data.code === 2000) {
  //   return res.data;
  // }
  // console.log(res)
  return res;
  // return Promise.reject(new Error(res));
}

//  提交微信进件表单

export async function wxSumbitMerchantApplyFor(data) {
  const res = await request.post('/business/wechatpay/merchantApplyFor', {
    merchantsapplyfor: data.merchantsapplyfor,
    businesslicense: data.businesslicense,
    bankaccount: data.bankaccount,
    settlement: data.settlement,
    businessinfo: data.businessinfo
  });
  // if (res.data.code === 2000) {
  //   return res.data;
  // }
  // console.log(res)
  return res;
  // return Promise.reject(new Error(res));
}

//   提交支付宝上传的MediaId

export async function zfbGetUploadMediaId(data) {
  const res = await request.post('/business/alipaymerchant/alipayUpload', data);
  // if (res.data.code === 2000) {
  //   return res.data;
  // }
  // console.log(res)
  return res;
  // return Promise.reject(new Error(res));
}

//   支付宝进件

export async function zfbMerchantCreate(data) {
  const res = await request.post(
    '/business/alipaymerchant/zfbMerchantCreate',
    data
  );
  if (res.data.code === 2000) {
    return res.data;
  }
  console.log(res);
  // return res
  return Promise.reject(new Error(res));
}

//  获取到进件的状态

export async function selectByPrimaryKey(data) {
  const res = await request.post(
    '/business/wechatpay/selectByPrimaryKey',
    data
  );
  if (res.data.code === 2000) {
    return res.data;
  }

  return Promise.reject(new Error(res));
}
